package implementor;

import daoInterface.ChequeDao;
import dbhandeling.Crude;
import dto.Cheque;

public class ChequeDaoImplementor extends Crude implements ChequeDao
{
String className=new Cheque().getClass().getName();
@Override
public void add(Cheque cheque) throws Exception
{
insert(cheque);
}
/***********************************************************/
@Override
public void update(Cheque cheque) throws Exception
{
super.update(className,"paymentMethodId",cheque.getpaymentMethodId()+"","autoChequeId",cheque.getautoChequeId()+"");
super.update(className,"amt",cheque.getamt()+"","autoChequeId",cheque.getautoChequeId()+"");
super.update(className,"bankName",cheque.getbankName()+"","autoChequeId",cheque.getautoChequeId()+"");
super.update(className,"branchName",cheque.getbranchName()+"","autoChequeId",cheque.getautoChequeId()+"");
super.update(className,"date",cheque.getdate()+"","autoChequeId",cheque.getautoChequeId()+"");
super.update(className,"status",cheque.getstatus()+"","autoChequeId",cheque.getautoChequeId()+"");
super.update(className,"transectionPaymentId",cheque.getTransectionPaymentId()+"","autoChequeId",cheque.getautoChequeId()+"");
}
/***********************************************************/
@Override
public void delete(Cheque cheque) throws Exception
{
super.delete(className,"autoChequeId",cheque.getautoChequeId()+"");
}
/***********************************************************/
@Override
public Cheque retrieve(String conditionField,String conditionValue) throws Exception
{
Cheque cheque=(Cheque) super.retreive(className,conditionField,conditionValue);
return cheque;
}
/***********************************************************/
@Override
public Cheque[] retrieveArray(String conditionField,String conditionValue) throws Exception
{
Cheque[] cheque;
Object[] obj=super.retreiveArrayOnCondition(className,conditionField, conditionValue);
cheque=new Cheque[obj.length];
for(int i=0;i<cheque.length;i++)
{
cheque[i]=(Cheque) obj[i];
}
return cheque;
}
/***********************************************************/
@Override
public Cheque[] retrieveAll() throws Exception
{
Cheque[] cheque;
Object[] obj=super.retreiveAll(className);
cheque=new Cheque[obj.length];
for(int i=0;i<cheque.length;i++)
{
cheque[i]=(Cheque) obj[i];
}
return cheque;
}
/***********************************************************/
public int getAutoGenratedKey()
{
	 int key=super.getAutoGenratedKey(className,"autoChequeId") ;
	 return key;
}
}
